﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using DigitalPlatform.Common.DialogWindowStyle;
using DigitalPlatform.Common.Event;
using DigitalPlatform.DAL;
using DigitalPlatform.IDAL;
using DigitalPlatform.ViewModels;
using DigitalPlatform.ViewModels.Pages;
using DigitalPlatform.Views;
using DigitalPlatform.Views.Pages;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using Prism.Unity;

namespace DigitalPlatform
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainView>();
        }
        //注册
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            //EFCORE相关注册
            containerRegistry.Register<ILocalEFService, LocalEFService>();
            containerRegistry.Register<ILocalDataAccess, LocalDataAccess>();




            //注册导航区域
            containerRegistry.RegisterForNavigation<MonitorPage>();
            containerRegistry.RegisterForNavigation<SettingsPage>();
            containerRegistry.RegisterForNavigation<TrendPage>();
            containerRegistry.RegisterForNavigation<ReportPage>();
            containerRegistry.RegisterForNavigation<AlarmPage>();
            // //注册显示的界面 
            // //1.内容页
            //containerRegistry.RegisterDialog<ComponentConfigView,ConfigViewModel>("ComponentConfigView");
            // //2.使用自定义的DialogWindow
            // containerRegistry.RegisterDialogWindow<DialogWindowBase>("DialogWindowBase");



        }
        protected override void ConfigureViewModelLocator()
        {
            base.ConfigureViewModelLocator();
            // view和viewmodel做匹配
            ViewModelLocationProvider.Register<LoginView, LoginViewModel>();
            ViewModelLocationProvider.Register<MainView, MainViewModel>();
            //page                           
            ViewModelLocationProvider.Register<MonitorPage, MonitorPageViewModel>();
            ViewModelLocationProvider.Register<SettingsPage, SettingsPageViewModel>();
            ViewModelLocationProvider.Register<TrendPage, TrendPageViewModel>();
            ViewModelLocationProvider.Register<ReportPage, ReportPageViewModel>();
            ViewModelLocationProvider.Register<AlarmPage, AlarmPageViewModel>();
            ViewModelLocationProvider.Register<ComponentConfigView>(() => Container.Resolve<ConfigViewModel>());
        }
        //初始化shell
        protected override void InitializeShell(Window shell)
        {
            var result = Container.Resolve<LoginView>().ShowDialog();
            if (result == true)
                shell.Show();
        }
    }
}
